package com.kuaiying.kuai.ying.model.sign;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.kuaiying.kuai.ying.model.print_shop.PrintshopModel;
import com.kuaiying.kuai.ying.model.user.UserModel;

public class SignModel extends Model<SignModel>{

	private static final long serialVersionUID = -6984293973714614243L;
	
	public static final SignModel me = new SignModel();
	
	private static final String USER_CACHE = "shop";
	
	public SignModel(){
		super( );
	}
	/**
	 * 所有 sql 与业务逻辑写在 Model 或 Service 中，不要写在 Controller 中，养成好习惯，有利于大型项目的开发与维护
	 */
	public Page<SignModel> paginate(int pageNumber, int pageSize) {
		return paginate(pageNumber, pageSize, "select *", "from   order by id asc");
	}
	
	/**
	 * 根據用戶名和用戶密碼驗證用戶是否存在
	 * @param userName：用戶名
	 * @param pwd：用戶密碼
	 * @return：用戶信息或null
	 */
	public SignModel getSignByNameAndDate(String userName, String Date){
		String sql = "select * from sign where usedid = '" + userName + "' and time ='" +  Date + "'" ;
		System.out.println( sql );
		
		SignModel sign = me.findFirst(sql);
		System.out.println( "123321" );
		return sign;
	}
	
	public boolean SignByNameAndDate(String userName, String Date, Integer gold,String flag){
		SignModel signModel = new SignModel();
		signModel.set("usedid", userName);
		signModel.set("time", Date);
		signModel.set("gold", gold);
		signModel.set("flag", flag);
		return signModel.save();
	}
	
}


